package com.redhat.redwork.widget;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.opensymphony.xwork2.util.ValueStack;

public class RedworkModels {
	
	protected TopicBridgeModel	topicBridge;
	protected GridToolbarModel	gridToolbar;
	protected GridFormModel		gridForm;
	protected GridModel 		grid;
	protected SubmitModel		submit;
	
	private ValueStack stack;
	private HttpServletRequest req;
	private HttpServletResponse res;

	public RedworkModels(ValueStack stack, HttpServletRequest req,
			HttpServletResponse res) {
		this.stack = stack;
		this.req = req;
		this.res = res;
	}

	public TopicBridgeModel getTopicBridge() {
		if (topicBridge == null)
			topicBridge = new TopicBridgeModel(stack, req, res);
		return topicBridge;
	}

	public GridModel getGrid() {
		if(grid == null){
			grid = new GridModel(stack, req, res);
		}
		return grid;
	}
	
	public GridFormModel getGridForm() {
		if(gridForm == null){
			gridForm = new GridFormModel(stack, req, res);
		}
		return gridForm;
	}

	public GridToolbarModel getGridToolbar() {
		if(gridToolbar == null){
			gridToolbar = new GridToolbarModel(stack, req, res);
		}
		return gridToolbar;
	}

	public SubmitModel getSubmit() {
		if(submit == null){
			submit = new SubmitModel(stack, req, res);
		}
		return submit;
	}
}
